package com.oppo.action;

import java.io.PrintWriter;
import java.util.List;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;
import com.oppo.bean.CarMaxBean;
import com.oppo.bean.UserBean;
import com.oppo.service.impl.UserDataService;
import com.oppo.tools.MyTools;


	@WebServlet("/UserAction")
	public class UserAction extends HttpServlet {
		private static final long serialVersionUID = 1L;
		protected void service(HttpServletRequest request, HttpServletResponse response) {
			try {
				System.out.println("xxxx");
				request.setCharacterEncoding("utf-8");// 设置接收编码类型
				response.setCharacterEncoding("utf-8");// 设置发送编码数据类型
				String user_id=request.getSession().getAttribute("user_id").toString();
				String[] user_psw=request.getParameterValues("pass1");
				UserBean one=new UserBean();
				System.out.println(user_id+user_psw);
				one.setUser_id(new Long(user_id));
				one.setUser_psw(user_psw[0]);
				int list=MyTools.getNewInstance(UserDataService.class).UpData(one);
				
		
				String strJson = JSON.toJSONStringWithDateFormat(list, "yyyy-MM-dd");// 借用第三方工具将list集合转换为json字符串
				PrintWriter JOIN = response.getWriter();//响应客户端的请求
				System.out.println(list);
				JOIN.write(strJson);//将字符串发送给客户端
				JOIN.flush();
				JOIN.close();
				

			} catch (Exception e) {
				System.out.println("用户信息接收发送错误");
				e.printStackTrace();
			}
		}

	}

